package com.kuang.demo.controller;

import com.kuang.demo.bean.BaseRespVo;
import com.kuang.demo.bo.gh.ExpressConfigBO;
import com.kuang.demo.bo.gh.MallConfigBO;
import com.kuang.demo.bo.gh.OrderConfigBO;
import com.kuang.demo.bo.gh.WxConfigBO;
import com.kuang.demo.service.ConfigService;
import com.kuang.demo.vo.QueryOrderConfigVO;
import com.kuang.demo.vo.QueryExpressConfigVO;
import com.kuang.demo.vo.QueryMallConfigVO;
import com.kuang.demo.vo.QueryWxConfigVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by 郭浩 on 2020/11/3 19:38
 */
@RestController
@RequestMapping("admin/config")
public class ConfigController {

    @Autowired
    ConfigService configService;
    @GetMapping("mall")
    public BaseRespVo getMall(){
        QueryMallConfigVO mall = configService.getMall();
        return BaseRespVo.ok(mall);
    }
    @GetMapping("express")
    public BaseRespVo getExpress(){
        QueryExpressConfigVO queryExpressConfigVO = configService.getExpress();
        return BaseRespVo.ok(queryExpressConfigVO);
    }
    @GetMapping("order")
    public BaseRespVo getOrder(){
        QueryOrderConfigVO queryOrderConfigVO = configService.getOrder();
        return BaseRespVo.ok(queryOrderConfigVO);
    }
    @GetMapping("wx")
    public BaseRespVo getWx(){
        QueryWxConfigVO queryWxConfigVO = configService.getWx();
        return BaseRespVo.ok(queryWxConfigVO);
    }
    public BaseRespVo mallConfig(@RequestBody MallConfigBO mallConfigBO){
        configService.mallConfig(mallConfigBO);
        return BaseRespVo.ok();
    }

    @PostMapping("express")
    public BaseRespVo expressConfig(@RequestBody ExpressConfigBO expressConfigBO){
        configService.expressConfig(expressConfigBO);
        return BaseRespVo.ok();
    }

    @PostMapping("order")
    public BaseRespVo orderConfig(@RequestBody OrderConfigBO orderConfigBO){
        if (orderConfigBO.getCskaoyanmall_order_comment() != null){
            System.out.println("sdsda");
        }
        configService.orderConfig(orderConfigBO);
        return BaseRespVo.ok();
    }

    @PostMapping("wx")
    public BaseRespVo wxConfig(@RequestBody WxConfigBO wxConfigBO){
        configService.wxConfig(wxConfigBO);
        return BaseRespVo.ok();
    }
}
